﻿using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using NExplorer.Core.Commands;

namespace NExplorer.Core
{
	internal class MiscMenuBuilder : SingleCategoryMenuBuilder
	{
		protected override void AddCommands()
		{
			SelectionInfo selectionInfo = ServiceManager.Explorer.SelectionInfo;
			IList<FileSystemInfo> selectedItems = ServiceManager.Explorer.SelectedItems;

			// New Folder: Only add when one folder is selcted
			if (selectedItems.Count == 1 && selectionInfo.IncludesDirectories)
			{
				Add<NewFolderContextMenuCommand>();
			}

			// New Folder: Only add when one exe is selected
			if (selectedItems.Count == 1 && selectionInfo.Extensions.Count == 1 && selectionInfo.Extensions[0] == new LowerCaseString("exe"))
			{
				Add<StartWithCommandLineArgumentsCommand>();
			}

			// Open in Windows Explorer: Only add when all items are directories
			if (selectionInfo.Extensions.Count == 0 && selectionInfo.IncludesDirectories)
			{
				Add<OpenInWindowsExplorerCommand>();
			}

			Add<CreateShortcutCommand>();
			
			if (Control.ModifierKeys == Keys.Shift)
			{
				Add<DeleteCommand>();
			}
			else
			{
				Add<SendToRecycleBinCommand>();
			}

			Add<RenameCommand>();

			Add<PropertiesCommand>("Properties");
		}

        protected override string Category
        {
            get { return "General"; }
        }
    }
}
